#pragma once
#include "interfaces/GuiPlugin.h"
#include <QToolBar>
#include <QFileDialog>
#include "StarlabMainWindow.h"

#ifdef DEBUG_PLUGIN_EDITPLUGINS
    #define DEB 
#else
    #define DEB if(false)
#endif

/// At any point there can be a single editing plugin active.
/// When a plugin is active (i.e. not suspended) it intercept 
/// all the input (i.e. mouse/keyboard) actions.
class gui_editplugins : public GuiPlugin{
    Q_OBJECT
    Q_INTERFACES(GuiPlugin)
    
public:    
    /// plugin constructor
    virtual void load(StarlabMainWindow* window);
    
private:   
    /// the action for the suspend mode (::load)
    QAction* suspendEditModeAct;
    /// Stores the actions (menu entries and buttons) associated with a plugin
    QMap<StarlabPlugin*, QAction*> pluginToActionMap;       
    /// Keeps track of the active plugin to avoid duplicated GUI
    /// This field is NULL unless a suspended Edit plugin exists
    EditPlugin* activeEditPlugin;
    
public slots:
    /// Starts an edit plugin, popping up its default GUI (also manages the suspend)
    void startEdit();
    void endEdit();
    void suspendEdit();
    
private:
    /// (initialized after ::load)
    StarlabMainWindow* window;
    Document* document;
    StarlabDrawArea* drawarea;    
};
